//初始化
$(function(){

	search();

});


//加载页面List
function search(){
	//取条件参数
	var searchParam = JSON.stringify({
		name:$("#Name").val(),
		searchTerm:$("#searchTerm").val(),
		infoStamp:$("#infoStamp").val(),
		status:$("#status").val(),
		startTime:$("#startTime").val(),
		endTime:$("#endTime").val(),
		pageNum:$("#pageNum").val(),
		pageSize:$("#pageSize").val(),
		radarName:$("#radarName").val(),
    	distributeTime:$("#distributeTime").val(),
    	staEndTime:$("#staEndTime").val(),
		isShow:$("#isShow").val(),
	});
	//请求Controller
	$.ajax({
        url : "/dlRadarTaskController/dlRadarTaskList",
        data : searchParam,
        type : 'post',
        dataType : 'json',
        contentType : 'application/json',
        success : successFunc,
        error : errorFunc
    });
}

function successFunc(data) {

	//循环打印表格
	if(data != null){
		var list =data.list;//取到数据集合
		var innerHtml= "";
		var num = (data.pageNum-1)*data.pageSize;
		var isShow = $("#isShow").val();
		$.each(list, function(i, row){
			var id = row.rtId;
			var infoStamp = row.infoStamp;
			var name = row.name;
			var radarName = row.radarName;//雷达名称
			var createTime = row.createTimeStr;
			var status = row.status;
			var duration = row.duration;
			var searchTerm = row.searchTerm;//站点名称
			var distributeTime = row.distributeTimeStr;
			var endTime = row.endTimeStr;
			var htmlTwo ="";
			var htmlOne = "<tr <c:if test='${i%2==0}'> class='odd'</c:if>>" 
						+ "<td algin='center'><span class='entityList'>"+(num+i+1)+"</td>"
						+ "<td algin='center'><span class='entityList'>"+infoStamp+"</td>"
						+ "<td algin='center'><span class='entityList'>"+name+"</td>"
						+ "<td algin='center'><span class='entityList'>"+searchTerm+"</td>"
						+ "<td algin='center'><span class='entityList'>"+createTime+"</td>"
						+ "<td algin='center'><span class='entityList'>"+status+"</td>"
						+ "<td algin='center'><span class='entityList'>"+duration+"</td>";
						if(isShow == "true"){
							htmlTwo =
							 "<td algin='center'><span class='entityList'>"+radarName+"</td>"
							+ "<td algin='center'><span class='entityList'>"+distributeTime+"</td>"
							+ "<td algin='center'><span class='entityList'>"+endTime+"</td>";
						}
						var htmlThree ="</tr>";
						innerHtml += htmlOne + htmlTwo + htmlThree;
		})
		$("#msg").html(innerHtml);
		//加载分页
		pageHelper(data.pageNum,data.lastPage);
	}else{

		alert("获取数据失败！");
	}
}
function errorFunc(data) {

	alert("获取数据失败！");
}

function onSelChange(){
	var selectVal = $("#mStatus").val();
	$("#status").val(selectVal);
}

function stationPut(){
	$.ajax({
        url : "/dlRadarTaskController/dlRadarTaskPut",
        type : 'get',
        success:function(data){
        	layui.use('layer', function(){
  			  var layer = layui.layer;
  			  layer.alert(' 站点分发成功！');
  			});              
        	window.location.reload();
        },
        error:function(e){
        	layer.alert(' 站点分发失败！');
        	console.log(e);
        }
    });
	
	
}